package com.sdx.console.system.service;

import com.ibeetl.admin.core.service.BaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.sdx.common.entity.DictBusiness;
import com.sdx.console.system.dao.DictBusinessDao;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 业务字典 Service
 */

@Service
@Transactional
public class DictBusinessService extends BaseService<DictBusiness>{

    @Resource
	private DictBusinessDao dictBusinessDao;

    public PageQuery<DictBusiness>queryByCondition(PageQuery query){
        PageQuery ret =  dictBusinessDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelDictBusiness(List<String> ids){
        try {
            dictBusinessDao.batchDelDictBusinessByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除业务字典失败", e);
        }
    }

    public List<DictBusiness> getListByType(Integer type) {
    	DictBusiness param = new DictBusiness();
    	param.setDictType(type);
    	param.setDictStatus(1);
    	return dictBusinessDao.template(param);
    }

	/**
	 * 大学类型列表
	 * @return
	 */
	public List<DictBusiness> getUnivTypeList() {
    	return getListByType(1);
    }

	/**
	 * 模块
	 * @return
	 */
	public List<DictBusiness> getModule() {
		return getListByType(2);
    }

    public List<DictBusiness> getModule(Integer type) {
        return getListByType(type);
    }

}
